from rest_framework import serializers

from goods.models import SPU, SPUSpecification, SpecificationOption


class SPUSimpleSerializer(serializers.ModelSerializer):
    class Meta:
        model=SPU
        fields=('id','name')


class SpecOptionSerializer(serializers.ModelSerializer):
    class Meta:
        model=SpecificationOption
        fields=('id','value')

class SPUSpecSerializer(serializers.ModelSerializer):
    options=SpecOptionSerializer(label='选项',many=True)
    class Meta:
        model=SPUSpecification
        fields=('id','name','options')



